# 导包
import requests, app


# 创建封装的员工类
class EmployeeApi:
    def __init__(self):
        self.url_employee = app.BASE_URL + "/api/sys/user"  # 员工模块url

    # 封装员工列表接口
    def query_employee_list(self, headers):
        return requests.get(url=self.url_employee, params={"page": "1", "size": "10"}, headers=headers)

    # 封装添加员工接口
    def add_employee(self, headers, jsonData):
        return requests.post(url=self.url_employee,
                             headers=headers,
                             json=jsonData)

    # 封装查询员工接口
    def query_employee(self, headers, target):
        url_query = self.url_employee + "/" + target  # 拼接修改员工url
        print("查询员工的url为", url_query)
        return requests.get(url_query, headers=headers)

    # 封装修改员工接口
    def update_employee(self, headers, target, jsonData):
        url_modify = self.url_employee + "/" + target  # 拼接修改员工url
        print("修改员工的url为", url_modify)
        return requests.put(url=url_modify,
                            headers=headers,
                            json=jsonData)

    # 封装删除员工接口
    def delete_empoyee(self, headers, target, ):
        url_delete = self.url_employee + "/" + target
        print("删除员工url为", url_delete)
        return requests.delete(url=url_delete, headers=headers)
